//
//  DoctorInfoController.m
//  KMedicine
//
//  Created by 曹牧 on 16/7/6.
//  Copyright © 2016年 caomu. All rights reserved.
//

#import "DoctorInfoController.h"

@interface DoctorInfoController ()

//---------1-----------
@property (nonatomic,weak) UIImageView * iconImageView;
@property (nonatomic,weak) UILabel * nameLabel;
@property (nonatomic,weak) UILabel * disLabel;
@property (nonatomic,weak) UILabel * timeLabel;
@property (nonatomic,weak) UIButton * auditBtn;

//-----------2-----------
@property (nonatomic,weak) UILabel * orderDocLabel;
@property (nonatomic,weak) UIView * line1;
@property (nonatomic,weak) UIView * line2;

//----------3----------------

@property (nonatomic,weak) UILabel * docNameLabel;
@property (nonatomic,weak) UILabel * hospitalLabel;
@property (nonatomic,weak) UILabel * dutyLabel;
@property (nonatomic,weak) UIImageView * imgV;

//--------4--------
@property (nonatomic,weak) UILabel * orderInfoLabel;
@property (nonatomic,weak) UIView * line3;
@property (nonatomic,weak) UIView * line4;

//-------5---------
@property (nonatomic,weak) UILabel * addrLabel;
@property (nonatomic,weak) UILabel * numLabel;
@property (nonatomic,weak) UILabel * numAddrLabel;

//---------6-----------
@property (nonatomic,weak) UIButton * resentBtn;
@property (nonatomic,weak) UIButton * cancelBtn;

@end

@implementation DoctorInfoController

- (void)setModel:(ApplyMedicineNoteModel *)model{
    
    _model = model;
    //搭建界面
    [self setupUI];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"预约医生信息详情";
    
}

- (void)setupUI{
    
    //----------------1----------
    
    UIImageView * iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"banner"]];
    self.iconImageView = iconImageView;
    [self.view addSubview:iconImageView];
    
    UILabel * nameLabel = [[UILabel alloc] init];
    nameLabel.text = self.model.patientName;
    self.nameLabel = nameLabel;
    [self.nameLabel sizeToFit];
    [self.view addSubview:nameLabel];
    
    UILabel * diseaseLabel = [[UILabel alloc] init];
    diseaseLabel.text = self.model.disease;
    self.disLabel = diseaseLabel;
    [self.disLabel sizeToFit];
    [self.view addSubview:diseaseLabel];
    
    UILabel * lookTimeLabel = [[UILabel alloc] init];
    lookTimeLabel.text = [NSString stringWithFormat:@"就诊:%@",self.model.look_time];
    self.timeLabel = lookTimeLabel;
    [self.timeLabel sizeToFit];
    [self.view addSubview:lookTimeLabel];
    
    UIButton * auditBtn = [[UIButton alloc] init];
    [auditBtn setTitle:self.model.audiStatus forState:UIControlStateNormal];
    [auditBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [auditBtn setBackgroundColor:kThemeColor];
    auditBtn.layer.cornerRadius  = 35;
    auditBtn.layer.masksToBounds = YES;
    self.auditBtn = auditBtn;
    [self.view addSubview:auditBtn];

    //----------------2----------
    UIView * line1 = [self getLineView];
    self.line1 = line1;
    [self.view addSubview:line1];
    
    UILabel * orderDocLabel = [[UILabel alloc] init];
    orderDocLabel.text = @"预约医生:";
    orderDocLabel.textColor = [UIColor grayColor];
    self.orderDocLabel = orderDocLabel;
    [self.orderDocLabel sizeToFit];
    [self.view addSubview:orderDocLabel];
    
    UIView * line2 = [self getLineView];
    self.line2 = line2;
    [self.view addSubview:line2];
    
    
    //----------------3----------
    
    UILabel * docNameLabel = [[UILabel alloc] init];
    docNameLabel.text = self.model.medicine;
    docNameLabel.textColor = [UIColor blackColor];
    self.docNameLabel = docNameLabel;
    [self.docNameLabel sizeToFit];
    [self.view addSubview:docNameLabel];
    
    
    UILabel * hospitalLabel = [[UILabel alloc] init];
    hospitalLabel.text = self.model.hospitalName;
    self.hospitalLabel = hospitalLabel;
    [self.hospitalLabel sizeToFit];
    [self.view addSubview:hospitalLabel];
    
    UILabel * dutyLabel = [[UILabel alloc] init];
    dutyLabel.text = self.model.medicineDuty;
    self.dutyLabel = dutyLabel;
    [self.dutyLabel sizeToFit];
    [self.view addSubview:dutyLabel];
    
    UIImageView * imgV = [[UIImageView alloc] init];
    imgV.image = [UIImage imageNamed:@"dijiaofankui"];
    self.imgV = imgV;
    [self.imgV sizeToFit];
    [self.view addSubview:imgV];
    
    
    //----------------4----------
    UIView * line3 = [self getLineView];
    self.line3 = line3;
    [self.view addSubview:line3];
    
    UILabel * orderInfoLabel = [[UILabel alloc] init];
    orderInfoLabel.text = @"预约医生:";
    orderInfoLabel.textColor = [UIColor grayColor];
    self.orderInfoLabel = orderInfoLabel;
    [self.orderInfoLabel sizeToFit];
    [self.view addSubview:orderInfoLabel];
    
    UIView * line4 = [self getLineView];
    self.line4 = line4;
    [self.view addSubview:line4];
    
    //----------------5----------
    
    [self getThirdUI];
    
    
    //----------------6----------
    
    UIButton * resentBtn = [[UIButton alloc] init];
    [resentBtn setTitle:@"短信重发" forState:UIControlStateNormal];
    [resentBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [resentBtn setBackgroundImage:[UIImage imageNamed:@"link_button_02"] forState:UIControlStateNormal];
    self.resentBtn = resentBtn;
    [self.view addSubview:resentBtn];
    
    UIButton * cancelBtn = [[UIButton alloc] init];
    [cancelBtn setTitle:@"取消预约" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [cancelBtn setBackgroundImage:[UIImage imageNamed:@"link_button_02"] forState:UIControlStateNormal];
    self.cancelBtn = cancelBtn;
    [self.view addSubview:cancelBtn];

    
}
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    [self.iconImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(64+20);
        make.left.equalTo(20);
        make.size.equalTo(CGSizeMake(60, 60));
    }];
    
    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView);
        make.left.equalTo(self.iconImageView.right).offset(20);
        
    }];
    
    [self.disLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.right).offset(20);
        make.top.equalTo(self.nameLabel);
        
    }];
    
    [self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel);
        make.bottom.equalTo(self.iconImageView);
    }];
    
    [self.auditBtn makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.iconImageView.centerY);
        make.size.equalTo(CGSizeMake(70, 70));
        make.centerX.equalTo(self.view.right).offset(-60);
    }];
    //------------2-------------
    [self.line1 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView.bottom).offset(10);
        make.left.equalTo(5);
    }];

    [self.orderDocLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.line1).offset(10);
    }];
    [self.line2 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.orderDocLabel.bottom).offset(10);
        make.left.equalTo(5);
    }];
    
    //---------------3-------------
    
    [self.docNameLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.line2.bottom).offset(10);
        make.left.equalTo(self.view).offset(20);
        
    }];
    [self.dutyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.docNameLabel.right).offset(20);
        make.top.equalTo(self.docNameLabel);
        
    }];
    
    [self.hospitalLabel makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.dutyLabel);
        make.top.equalTo(self.docNameLabel.bottom).offset(20);
    }];
    
    [self.imgV makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(CGSizeMake(100, 40));
        make.centerX.equalTo(self.auditBtn);
        make.top.equalTo(self.line2).offset(20);
        
    }];
    
    //-------------4--------------
    [self.line3 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hospitalLabel.bottom).offset(10);
        make.left.equalTo(5);
    }];
    
    [self.orderInfoLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.line3).offset(10);
    }];
    [self.line4 makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.orderInfoLabel.bottom).offset(10);
        make.left.equalTo(5);
    }];
    
    //-----------5-------------
    
    [self getThirdLayout];
    
    
    //-----------6---------
    [self.resentBtn makeConstraints:^(MASConstraintMaker *make) {
   
        make.size.equalTo(CGSizeMake(130, 40));
        make.right.equalTo(self.view.centerX).offset(-20);
        make.bottom.equalTo(self.view).offset(-20);
    }];
    
    [self.cancelBtn makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.equalTo(CGSizeMake(130, 40));
        make.left.equalTo(self.view.centerX).offset(20);
        make.bottom.equalTo(self.view).offset(-20);
    }];
    
    
}

- (void)getThirdUI{
    /*
     @property (nonatomic,weak) UILabel * addrLabel;
     @property (nonatomic,weak) UILabel * numLabel;
     @property (nonatomic,weak) UILabel * numAddrLabel;
     */
    
    UILabel * addrLabel = [[UILabel alloc] init];
    addrLabel.text = @"就诊时间: 上海长征医院2号楼心血管内科";
    self.addrLabel = addrLabel;
    [self.addrLabel sizeToFit];
    [self.view addSubview:addrLabel];
    
    UILabel * numLabel = [[UILabel alloc] init];
    numLabel.text = @"取号时间: 9:00 - 10:00";
    self.numLabel = numLabel;
    [self.numLabel sizeToFit];
    [self.view addSubview:numLabel];
    
    UILabel * numAddrLabel = [[UILabel alloc] init];
    numAddrLabel.text = @"取号地址: 上海长征医院住院部";
    self.numAddrLabel = numAddrLabel;
    [self.numAddrLabel sizeToFit];
    [self.view addSubview:numAddrLabel];
    
    
    
}
- (void)getThirdLayout{
    
    [self.addrLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.line4).offset(20);

    }];
    [self.numLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.addrLabel.bottom).offset(20);
    }];
    [self.numAddrLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.top.equalTo(self.numLabel.bottom).offset(20);
    }];
    
    
}

- (UIView *)getLineView{

    UIView * lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor grayColor];

    [lineView makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(CGSizeMake(365, 1));
    }];
    return lineView;
}


@end
